export default function getDoughnut(optionSet = []) {
  // eslint-disable-next-line array-callback-return
  const legendArr = optionSet.map((e, i) => {
    const x = i % 2 === 0 ? '55%' : '75%';
    return {
      orient: 'vertical',
      icon: 'circle',
      x: x,
      y: 20 + parseInt(i / 2) * 15 + '%', // 0 1 => 20,2 3 => 35, 4 5 => 50, 6 7 => 65
      align: 'left',
      itemWidth: 10,
      itemHeight: 10,
      data: [e.name],
      textStyle: {
        fontSize: 12,
        color: '#fff'
      }
    };
  });
  const option = {
    color: [
      '#00FFFF',
      '#556FB5',
      '#FACD89',
      '#0068B7',
      '#F29B76',
      '#22AC38',
      '#AA89BD',
      '#004986'
    ],
    tooltip: {
      trigger: 'item',
      formatter: '<br/>{b} : {c} ({d}%)'
    },
    legend: legendArr,
    calculable: true,
    series: [
      {
        name: '半径模式',
        type: 'pie',
        radius: [20, 90],
        center: ['32%', '50%'],
        roseType: 'radius',
        label: {
          normal: {
            show: false
          },
          emphasis: {
            show: true
          }
        },
        lableLine: {
          normal: {
            show: false
          },
          emphasis: {
            show: true
          }
        },
        data: optionSet
      }
    ]
  };

  return option;
}
